package com.jsu.clubmanagementsystem.model.enums;

import lombok.Getter;

/**
 * 申请类型枚举
 */
@Getter
public enum ApplicationTypeEnum {

    DELETE_USER(0, "账号注销"),
    JOIN_CLUB(1, "加入社团"),
    QUIT_CLUB(2, "退出社团"),
    ENGAGE_ACTIVITY(3, "参与活动"),
    QUIT_ACTIVITY(4, "退出活动"),
    CREATE_CLUB(5, "创建社团"),
    DELETE_CLUB(6, "注销社团"),
    CHANGE_CLUB_INFO(7, "修改社团信息"),
    CREATE_ACTIVITY(8, "创建活动"),
    DELETE_ACTIVITY(9, "删除活动"),
    CHANGE_ACTIVITY_INFO(10, "修改活动信息");

    private final Integer code;
    private final String description;

    ApplicationTypeEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据代码获取枚举类型
     *
     * @param code 类型代码
     * @return 对应的枚举类型，若不存在则返回null
     */
    public static ApplicationTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }

        for (ApplicationTypeEnum type : ApplicationTypeEnum.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }
}
